package com.ynny.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class UserDaoImpl implements UserDao{

    @Autowired
    JdbcTemplate jdbcTemplate;

    @Override
    public int updateUserBalance(Integer userId, Integer price) {
        String sql = "UPDATE t_user SET balance=balance - ? WHERE user_id=?";

        return jdbcTemplate.update(sql, price, userId);
    }
}
